What is faster: multiple `send`s or using buffering?
        Posted  
        
            by dauerbaustelle
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by dauerbaustelle
        
        
        
        Published on 2010-04-14T15:04:48Z
        Indexed on 
            2010/04/14
            15:13 UTC
        
        
        Read the original article
        Hit count: 275
        
I'm playing around with sockets in C/Python and I wonder what is the most efficient way to send headers from a Python dictionary to the client socket.
My ideas:
- use a 
sendcall for every header. Pros: No memory allocation needed. Cons: manysendcalls -- probably error prone; error management should be rather complicated - use a buffer. Pros: one 
sendcall, error checking a lot easier. Cons: Need a buffer :-)malloc/reallocshould be rather slow and using a (too) big buffer to avoidrealloccalls wastes memory. 
Any tips for me? Thanks :-)
© Stack Overflow or respective owner